//
//  RWBalanceViewController.m
//  RedWine
//
//  Created by Liufangfang on 2016/12/28.
//  Copyright © 2016年 HuiBangKe. All rights reserved.
//

#import "RWBalanceViewController.h"
#import "RWBalanceGoodsViewCell.h"
#import "RWAddressViewController.h"
#import "RWDeliveryViewController.h"
#import "RWBillViewController.h"
#import "RWOrderRemarksViewController.h"
#import "RWBalancePayViewController.h"
#import "RWPaySuccessViewController.h"

#import "RWBalanceModel.h"
#import "RWAddressModel.h"
#import "ShopCartModel.h"

@interface RWBalanceViewController ()<RWDeliveryViewControllerDelegate, RWBillViewControllerDelegate,RWOrderRemarksViewDelegate>{

    NSArray *section0Titles;
    NSArray *section1Titles;
    NSArray *section0DetailTitles;
    NSMutableArray *section1DetailTitles;
    NSUInteger shopCartCount;
}

@property (nonatomic, copy) RWBalanceModel *balanceModel;
@property (nonatomic, copy) RWAddressModel *addressModel;
@property (nonatomic, copy) NSMutableArray *shopCartModels;
@property (nonatomic, copy) RWBalanceMoneyModel *balanceMoneyModel;

@property (nonatomic, strong) UILabel *deliveryDetailLab;

@property (nonatomic, strong) NSString *currentDeliveryStyle;

@property (nonatomic, copy) NSString *jointBillParam;

@end

@implementation RWBalanceViewController

#pragma mark - View LifeCycle

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initObjects];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self loadDatas];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Load Datas

- (void)initObjects{
    
    section0Titles = @[@"配送方式", @"支付方式", @"酒券余额", @"余额抵扣"];
    section1Titles = @[@"发票信息", @"订单备注"];
    //section1DetailTitles = @[@"暂不开发票", @"请尽快发货"];
    section1DetailTitles = [NSMutableArray arrayWithObjects:@"发票信息",@"订单备注", nil];
    _currentDeliveryStyle = @"送货时间不限";
    
    _balanceModel = [[RWBalanceModel alloc] init];
    _addressModel = [[RWAddressModel alloc] init];
    _shopCartModels = [[NSMutableArray alloc] init];
    _balanceMoneyModel = [[RWBalanceMoneyModel alloc] init];
}

- (void)loadDatas{

    FTYUser *user = [FTYUser sharedUser];
    [FTYHTTPManager postInfoWithSubUrl:[NSString stringWithFormat:@"/shop/ybkapi.php?act=ybkapi&op=settlement&member_id=%@&token=%@&cart_id=%@", user.userID, user.userToken, _cartIDs] parameters:nil block:^(id result, NSError *error) {
        
        if (!error) {
            
            DLog(@"结算====%@", result);
            FTYBaseShopCartModel *baseModel = [[FTYBaseShopCartModel alloc] init];
            baseModel = [FTYBaseShopCartModel mj_objectWithKeyValues:result];
            FTYErrorInfoModel *errorInfo = [FTYErrorInfoModel mj_objectWithKeyValues:baseModel.err];
            
            if (0 == errorInfo.errorcode) {
                
                //获取数据
                _balanceModel = [RWBalanceModel mj_objectWithKeyValues:baseModel.info];
                _addressModel = [RWAddressModel mj_objectWithKeyValues:_balanceModel.addr];
                if (_shopCartModels.count>0) {
                    [_shopCartModels removeAllObjects];
                }
                [_shopCartModels addObjectsFromArray:_balanceModel.cart_goods];
                
                shopCartCount = _shopCartModels.count;
                _balanceMoneyModel = [RWBalanceMoneyModel mj_objectWithKeyValues:_balanceModel.money];
                
                //配置UI
                [self setNavigation];
                [self setBalanceUI];
            } else if(4 == errorInfo.errorcode){
                
                //token过期，重新登录
                [FTYLoginManager reLoginFromViewController:self];
            } else {
                [[FTYToastView alloc] addTitle:errorInfo.errorinfo addView:self.view];
            }
        } else {
            
        }
    }];
}

#pragma mark - Config UI

- (void)setNavigation{
    
    self.title = @"结算中心";
}

- (void)setBalanceUI{
    
    _balanceTV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, FTY_SCREEN_WIDTH, FTY_SCREEN_HEIGHT - (FTY_STATUS_HEIGHT + FTY_NAVIGATION_HEIGHT)) style:UITableViewStylePlain];
    [self.view addSubview:_balanceTV];
    _balanceTV.backgroundColor = [UIColor whiteColor];
    _balanceTV.separatorStyle = UITableViewCellSeparatorStyleNone;
    _balanceTV.dataSource = self;
    _balanceTV.delegate = self;
    _balanceTV.tableHeaderView = [self createTVHeader];
    _balanceTV.tableFooterView = [self creteToBalance];
}

#pragma mark - Config Invoke Methods

- (UIView *)createTVHeader{

    UIView *headerV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FTY_SCREEN_WIDTH, 86.*FTY_HEIGHT_BASE)];
    
    headerV.userInteractionEnabled = YES;
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(addAddressAction:)];
    [headerV addGestureRecognizer:tapGesture];
    
    //收货人信息
    UIButton *positionIcon = [[UIButton alloc] init];
    [headerV addSubview:positionIcon];
    [positionIcon setImage:[UIImage imageNamed:@"position_icon"] forState:UIControlStateNormal];
    [positionIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(headerV.mas_centerY);
        make.left.mas_offset(10.*FTY_WIDTH_BASE);
        make.width.height.mas_offset(25.*FTY_WIDTH_BASE);
    }];
    
    if (_addressModel.address_id.length > 0) {
        
        UILabel *nameLab = [[UILabel alloc] init];
        [headerV addSubview:nameLab];
        nameLab.text = [NSString stringWithFormat:@"%@ %@", _addressModel.true_name, _addressModel.mob_phone];
        nameLab.textColor = [FTYColor blackColor];
        nameLab.font = FTY_FONTTSIZE(14);
        [nameLab sizeToFit];
        [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_offset(20.*FTY_HEIGHT_BASE);
            make.left.mas_equalTo(positionIcon.mas_right).offset(10.*FTY_WIDTH_BASE);
            make.right.mas_equalTo(-60.*FTY_WIDTH_BASE);
        }];
        
        UILabel *addressLab = [[UILabel alloc] init];
        [headerV addSubview:addressLab];
        //addressLab.text = _addressModel.area_info;
        addressLab.text = [NSString stringWithFormat:@"%@ %@",_addressModel.area_info,_addressModel.address];
        addressLab.textColor = [FTYColor blackColor];
        addressLab.font = FTY_FONTTSIZE(14);
        addressLab.numberOfLines = 2;
        [addressLab sizeToFit];
        [addressLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(nameLab.mas_bottom).offset(10.*FTY_HEIGHT_BASE);
            make.left.mas_equalTo(nameLab.mas_left);
            make.right.mas_equalTo(nameLab.mas_right);
        }];
        
        UIButton *arrowIcon = [[UIButton alloc] init];
        [headerV addSubview:arrowIcon];
        [arrowIcon setImage:[UIImage imageNamed:@"right_icon"] forState:UIControlStateNormal];
        [arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(positionIcon.mas_top);
            make.right.mas_equalTo(-10.*FTY_WIDTH_BASE);
            make.width.height.mas_equalTo(30.*FTY_WIDTH_BASE);
        }];
        
        //中间线
        UIView *line = [[UIView alloc] init];
        [headerV addSubview:line];
        line.backgroundColor = [FTYColor grayColor];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(85.*FTY_HEIGHT_BASE);
            make.left.right.mas_equalTo(0);
            make.height.mas_equalTo(.5*FTY_HEIGHT_BASE);
        }];
    } else {
        
        UILabel *addAddrLab = [[UILabel alloc] init];
        [headerV addSubview:addAddrLab];
        addAddrLab.text = @"请添加地址";
        addAddrLab.textColor = [UIColor blackColor];
        addAddrLab.font = FTY_FONTTSIZE(15);
        [addAddrLab sizeToFit];
        [addAddrLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(headerV.mas_centerY);
            make.left.mas_equalTo(positionIcon.mas_right).offset(10.*FTY_WIDTH_BASE);
        }];
    }
    
    return headerV;
}

- (UIView *)creteToBalance{
    
    UIView *toBalanceV = [[UIView alloc] initWithFrame:CGRectMake(0, 40.*FTY_HEIGHT_BASE, FTY_SCREEN_WIDTH, 100.*FTY_HEIGHT_BASE)];
    
    UILabel *reminderLab = [[UILabel alloc] init];
    [toBalanceV addSubview:reminderLab];
    reminderLab.text = @"优先使用酒券和余额支付";
    reminderLab.textAlignment = NSTextAlignmentCenter;
    reminderLab.textColor = [FTYColor blackColor];
    reminderLab.font = FTY_FONTTSIZE(15);
    [reminderLab sizeToFit];
    [reminderLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(10.*FTY_HEIGHT_BASE);
        make.left.mas_offset(10*FTY_WIDTH_BASE);
        make.right.mas_offset(-10.*FTY_WIDTH_BASE);
    }];

    UIButton *balanceBtn = [[UIButton alloc] init];
    [toBalanceV addSubview:balanceBtn];
    balanceBtn.layer.masksToBounds = YES;
    balanceBtn.layer.cornerRadius = 15.*FTY_WIDTH_BASE;
    balanceBtn.backgroundColor = [FTYColor getMainColorWithAlpha:1.];
    NSString *payMoney = [self getShouldPayMoney];
    [balanceBtn setTitle:[NSString stringWithFormat:@"应付¥%@元  去支付", payMoney] forState:UIControlStateNormal];
    [balanceBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    balanceBtn.titleLabel.font = FTY_FONTTSIZE(15);
    [balanceBtn addTarget:self action:@selector(balanceBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    [balanceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(reminderLab.mas_bottom).offset(15.*FTY_HEIGHT_BASE);
        make.left.right.mas_equalTo(reminderLab);
        make.height.mas_offset(40.*FTY_HEIGHT_BASE);
    }];
    
    return toBalanceV;
}

//#pragma mark - Notificaiton Method

//- (void)configNotification{
//
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshData:) name:@"RWRefreshPayData" object:nil];
//}
//
//#pragma mark - Notificaiton Invoke Methods
//
//- (void)refreshData:(NSNotification *)notify{
//
//    NSString *currentDeliveryStyle = [notify.object objectForKey:@"currentDeliveryStyle"];
//    deliveryStyle = currentDeliveryStyle;
//    _deliveryDetailLab.text = currentDeliveryStyle;
//    [_balanceTV reloadData];
//}

#pragma mark - <UITableViewDataSource>

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    if (0 == section) {
        return shopCartCount;
    } else if (1 == section) {
        return 4;
    } else {
        return 2;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    return 10.*FTY_HEIGHT_BASE;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (0 == indexPath.section) {
        return 100.*FTY_HEIGHT_BASE;
    } else {
        return 50.*FTY_HEIGHT_BASE;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString * const balanceGoodsID = @"shopCartGoodsID";
    RWBalanceGoodsViewCell *balanceGoodsCell = [tableView dequeueReusableCellWithIdentifier:balanceGoodsID];
    
    static NSString * const balanceOtherID = @"balanceOtherID";
    UITableViewCell *balanceOtherCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:balanceOtherID];
    balanceOtherCell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    balanceOtherCell.textLabel.font = FTY_FONTTSIZE(14);
    balanceOtherCell.detailTextLabel.font = FTY_FONTTSIZE(12);
    
    NSInteger section = indexPath.section;
    NSInteger row = indexPath.row;
    /*
    NSString *wineBalance = [NSString stringWithFormat:@"-¥%@", [NSNumber numberWithInteger:_balanceMoneyModel.drinksbalance]];
    NSString *balance = [NSString stringWithFormat:@"-¥%@", [NSNumber numberWithInteger:_balanceMoneyModel.balance]];
    section0DetailTitles = [NSArray arrayWithObjects:_currentDeliveryStyle, @"在线支付", wineBalance, balance, nil];
    */
    section0DetailTitles = [self getBalanceArr];
    switch (section) {
        
        case 0:{
            if (!balanceGoodsCell) {
                
                balanceGoodsCell = [[RWBalanceGoodsViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:balanceGoodsID];
            }
            [balanceGoodsCell loadDataWithModel:_shopCartModels[row]];
            return balanceGoodsCell;
            break;
        }
            
        case 1:{
            
            balanceOtherCell.textLabel.text = section0Titles[row];
    
            if (0 == row) {
                
                _deliveryDetailLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 30)];
                [balanceOtherCell addSubview:_deliveryDetailLab];
                _deliveryDetailLab.textColor = [UIColor grayColor];
                _deliveryDetailLab.text = _currentDeliveryStyle;
                _deliveryDetailLab.font = FTY_FONTTSIZE(12);
                [_deliveryDetailLab sizeToFit];
                [_deliveryDetailLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.centerY.mas_equalTo(balanceOtherCell.mas_centerY);
                    make.right.mas_offset(-35.*FTY_WIDTH_BASE);
                    make.height.mas_offset(30.*FTY_HEIGHT_BASE);
                }];
            } else {
                balanceOtherCell.detailTextLabel.text = section0DetailTitles[row];
                if (row != 1) {
                    balanceOtherCell.detailTextLabel.textColor = [FTYColor getMainColorWithAlpha:1.];
                }
            }
            break;
        }
        case 2:{
            
            balanceOtherCell.textLabel.text = section1Titles[row];
            balanceOtherCell.detailTextLabel.text = section1DetailTitles[row];
            break;
        }
        default:
            break;
    }
    
    //底部线
    UIView *bLine = [[UIView alloc] init];
    [balanceOtherCell addSubview:bLine];
    bLine.backgroundColor = [FTYColor grayColor];
    [bLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.mas_offset(0);
        make.height.mas_offset(.5*FTY_HEIGHT_BASE);
    }];
    
    return balanceOtherCell;
}

#pragma mark - <UITableViewDelegate>

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    NSInteger section = indexPath.section;
    NSInteger row = indexPath.row;
    
    if (1 == section) {
        
        if (0 == row) {
         
            //配送方式
            RWDeliveryViewController *deliveryVC = [[RWDeliveryViewController alloc] init];
            deliveryVC.delegate = self;
            [self.navigationController pushViewController:deliveryVC animated:YES];
        }
    } else if (2 == section) {
        
        if (0 == row) {
        
            //发票信息
            RWBillViewController *billVC = [[RWBillViewController alloc] init];
            billVC.cart_id = [_shopCartModels[0] objectForKey:@"cart_id"];
            billVC.address_id = _addressModel.address_id;
            billVC.delegate = self;
            [self.navigationController pushViewController:billVC animated:YES];
        } else {
        
            //订单备注
            RWOrderRemarksViewController *orderRemarksVC = [[RWOrderRemarksViewController alloc] init];
            orderRemarksVC.delegate = self;
            [self.navigationController pushViewController:orderRemarksVC animated:YES];
        }
    }
}

#pragma mark - <RWDeliveryViewControllerDelegate>

- (void)selectDeliveryViewController:(RWDeliveryViewController *)deliveryVC didSelectDeliveryStyle:(NSString *)deliveryStyle{

    _currentDeliveryStyle = deliveryStyle;
    self.deliveryDetailLab.text = deliveryStyle;
    [_balanceTV reloadData];
}

#pragma mark - <RWBillViewControllerDelegate>

- (void)sendDataWithParam:(NSString *)param{

    _jointBillParam = param;
    
    NSString *invoiceTitle = [self getInvoiceInfo:@"inv_title" fromDataSource:_jointBillParam];
    NSString *invoiceContent = [self getInvoiceInfo:@"inv_content" fromDataSource:_jointBillParam];
    invoiceTitle = [NSString stringWithFormat:@"%@ %@",invoiceTitle,invoiceContent];
    if (invoiceTitle) {
        [section1DetailTitles replaceObjectAtIndex:0 withObject:invoiceTitle];
    }
}

#pragma mark - <RWOrderRemarksViewControllerDelegate>
- (void)sendRemarkData:(NSString *)param
{
    NSString *orderRemark = param;
    if (orderRemark) {
        [section1DetailTitles replaceObjectAtIndex:1 withObject:orderRemark];
    }
}
//从参数中获取发票抬头
- (NSString *)getInvoiceInfo:(NSString *)param fromDataSource:(NSString *)dataSource
{
    if (dataSource) {
        NSArray *paramArr = [dataSource componentsSeparatedByString:@"&"];
        for (NSString *str in paramArr) {
            if ([str hasPrefix:param]) {
                NSArray *titleArr = [str componentsSeparatedByString:@"="];
                if (titleArr.count == 2) {
                    NSString *inv_title = [titleArr objectAtIndex:1];
                    return inv_title;
                }
                
            }
        }
    }
    
    return nil;
}

- (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString {
    if (jsonString == nil) {
        return nil;
    }
    NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSError *err;
    NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData
                                                        options:NSJSONReadingMutableContainers
                                                          error:&err];
    if(err) {
        NSLog(@"json解析失败：%@",err);
        return nil;
    }
    return dic;
}


#pragma mark - Private Invoke Methods

- (void)addAddressAction:(id)sender{

    RWAddressViewController *addressVC = [[RWAddressViewController alloc] init];
    [self.navigationController pushViewController:addressVC animated:YES];
}

- (void)balanceBtnAction:(UIButton *)btn{
    //如果余额足够在线支付，否则支付宝或者微信支付
//    NSString *accountBenefit = [FTYUser sharedUser].userAccountBalance;
//    NSString *wineBalance = [FTYUser sharedUser].userWineBalance;
//    NSInteger money;
    
    NSString *payMoney = [self getShouldPayMoney];
    
    if (payMoney.integerValue == _balanceModel.sum.integerValue) {
        [self balancePay:nil];
    }else{
        [self onLinePay];
    }
    
    //[self balancePay:@"8000508340458961"];
}

- (void)balancePay:(NSString *)orderSN
{
    RWBalancePayViewController *balancePayVC = [[RWBalancePayViewController alloc] init];
    balancePayVC.cartIDs = _cartIDs;
    balancePayVC.addressID = _addressModel.address_id;
    balancePayVC.jointBillParam = _jointBillParam;
    balancePayVC.goodNum = [NSString stringWithFormat:@"%ld", _shopCartModels.count];
    NSString *payMoney = [self getShouldPayMoney];
    balancePayVC.money = payMoney;
    balancePayVC.orderSN = orderSN;
    [self.navigationController pushViewController:balancePayVC animated:YES];
}
- (void)onLinePay
{
    FTYUser *user = [FTYUser sharedUser];
    [FTYHTTPManager postInfoWithSubUrl:[NSString stringWithFormat:@"/shop/ybkapi.php?act=ybkapi&op=neworder&member_id=%@&token=%@&cart_id=%@&address_id=%@&%@&account=%@", user.userID, user.userToken, _cartIDs, _addressModel.address_id, _jointBillParam,@"balance,drinksbalance"] parameters:nil block:^(id result, NSError *error) {
        
        if (!error) {
            
            DLog(@"====%@", result);
            FTYBaseShopCartModel *baseModel = [[FTYBaseShopCartModel alloc] init];
            baseModel = [FTYBaseShopCartModel mj_objectWithKeyValues:result];
            FTYErrorInfoModel *errorInfo = [FTYErrorInfoModel mj_objectWithKeyValues:baseModel.err];
            
            if (0 == errorInfo.errorcode) {
                
                NSLog(@"onLinePay:在线支付成功");
                NSString *payMoney = [self getShouldPayMoney];
                
                if (payMoney.integerValue == 0) {
                    
                    RWPaySuccessViewController *paySuccessController = [[RWPaySuccessViewController alloc] init];
                    [self.navigationController pushViewController:paySuccessController animated:YES];
                    paySuccessController.orderId = [baseModel.info objectForKey:@"order_sn"];
                    paySuccessController.payMoney = _balanceModel.sum;
                }else{
                    [self balancePay:[baseModel.info objectForKey:@"order_sn"]];
                }
                
            } else {
                [[FTYToastView alloc] addTitle:errorInfo.errorinfo addView:self.view];
            }
        } else {
            
        }
    }];
}

//获取应付金额
- (NSString *)getShouldPayMoney
{
    NSString *shouldPay = @"";
    
    NSString *accountBenefit = [FTYUser sharedUser].userAccountBalance;
    NSString *wineBalance = [FTYUser sharedUser].userWineBalance;
    
    if (accountBenefit.integerValue + wineBalance.integerValue >= _balanceModel.sum.integerValue) {
        
        shouldPay = @"0";
    }else{
        NSInteger money = -(accountBenefit.integerValue + wineBalance.integerValue - _balanceModel.sum.integerValue);
        shouldPay = [NSString stringWithFormat:@"%ld",money];
    }
    return shouldPay;
}

//获取酒券余额和余额抵扣
- (NSArray *)getBalanceArr
{
    NSString *wineValue = @"";//酒券余额
    NSString *balanceValue = @"";//余额抵扣
    NSInteger accountBenefit = [FTYUser sharedUser].userAccountBalance.integerValue;
    NSInteger wineBalance = [FTYUser sharedUser].userWineBalance.integerValue;
    NSInteger sum = _balanceModel.sum.integerValue;
    if (wineBalance >= sum) {
        wineValue = [NSString stringWithFormat:@"-¥%@",[NSNumber numberWithInteger:sum]];
    }else if (accountBenefit >= sum){
        balanceValue = [NSString stringWithFormat:@"-¥%@",[NSNumber numberWithInteger:sum]];
    }else if (wineBalance + accountBenefit <= sum){
        wineValue = [NSString stringWithFormat:@"-¥%@",[NSNumber numberWithInteger:wineBalance]];
        balanceValue = [NSString stringWithFormat:@"-¥%@",[NSNumber numberWithInteger:accountBenefit]];
    }else if (wineBalance + accountBenefit > sum){
        wineValue = [NSString stringWithFormat:@"-¥%@",[NSNumber numberWithInteger:wineBalance]];
        balanceValue = [NSString stringWithFormat:@"-¥%@",[NSNumber numberWithInteger:sum-accountBenefit]];
    }
    NSArray *arr = [NSArray arrayWithObjects:_currentDeliveryStyle,@"在线支付",wineValue,balanceValue,nil];
    return arr;
}
@end
